import { Material, Mesh, Object3D } from "three";
import { IEditorHistoryOptions } from "../EditorHistory";
import EditorCommand, { EnumEditorCommandName, EnumEditorCommandType } from "./EditorCommands";
import { IUserData } from "../EditorModels";

export interface IEditorSetPostionCommandsOptions extends IEditorHistoryOptions {
    object: Mesh,
    newMaterial: Material | Material[],
    oldMaterial: Material | Material[]
}
export default class EditorSetMaterialCommands extends EditorCommand {
    newMaterial: Material | Material[]
    oldMaterial: Material | Material[]
    object: Mesh
    constructor(options: IEditorSetPostionCommandsOptions) {
        super(options);
        this.type = EnumEditorCommandType.SetMaterialCommand;
        this.name = EnumEditorCommandName.SetMateria;
        this.newMaterial = options.newMaterial;
        this.oldMaterial = options.oldMaterial;
        this.object = options.object;
    }

    execute(): void {
        this.object.material = this.newMaterial;
        (this.object.userData as IUserData).oldMaterial = this.oldMaterial
    }
    undo(): void {
        this.object.material = this.oldMaterial;
        (this.object.userData as IUserData).oldMaterial = this.newMaterial
    }
    update(params: this): void {
        throw new Error("Method not implemented.");
    }
}